<script src="/ueditor/ueditor.config.js"></script>
<script src="/ueditor/ueditor.all.min.js"></script>
<script src="/ueditor/lang/zh-cn/zh-cn.js"></script>

<div class="content">
    <form id="edit-form" class="form-horizontal nice-validator n-default n-bootstrap" role="form" data-toggle="validator" method="POST" action="" novalidate="novalidate" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$res.id}"/>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">标题:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="title" class="form-control" name="title" value="{$res.title}" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">副标题:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="title2" class="form-control" name="title2" value="{$res.title2}" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">外链地址:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="linkto" class="form-control" name="linkto" type="text" value="{$res.linkto}">
            </div>
        </div>
      <!--  <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">媒体类型:</label>
            <div class="col-xs-12 col-sm-8" id="typeradio">
                <input  name="m_type" id="radio1" value="0" type="radio" {if condition="$res.m_type eq 0"}checked="checked"{/if}>图片
                <input  name="m_type" id="radio2" value="1" type="radio" {if condition="$res.m_type eq 1"}checked="checked"{/if}>视频
            </div>
        </div>-->

       <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">媒体地址:</label>
           <input  name="m_type"  value="{$res.m_type}" type="hidden">
               {if condition="$res.m_type eq 0"}
                <div class="col-xs-12 col-sm-8" id="imgdiv">
                    <img src="{$res.imgurl}" alt="" id="lod_pic" style="display: block; margin-bottom: 10px; width:250px;height:auto;" >
                    <input id="imgurl"  name="imgurl" type="hidden">
                   <button type="button" onclick="img_sub();" style="display:block;">图片上传</button>
                </div>
                {else/}
                <div class="col-xs-12 col-sm-8" id="videodiv">
                    <video id="video" style="width:auto;height:200px;" controls>
                        <source src="{$res.imgurl}"  type="video/mp4" >
                    </video>
                    <input name="imgurl" type="file" style="display:block;" accept="video/mp4"/>
                </div>
            {/if}
        </div>



        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">内容:</label>
            <div class="col-xs-12 col-sm-8">
                <textarea name="info"  id="info">{$res.info}</textarea>
            </div>
        </div>

        <div class="form-group layer-footer">
            <label class="control-label col-xs-12 col-sm-2"></label>
            <div class="col-xs-12 col-sm-8">
                <button type="button" class="btn btn-success btn-embossed" onclick="sub();">确定</button>
                <a href="/admin/product/index_img?id={$res.p_id}" class="btn btn-default btn-embossed">返回</a>
            </div>
        </div>
    </form>

</div>
<script language="javascript" type="text/javascript" src="/assets/My97DatePicker/jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript" src="/assets/libs/fastadmin-layer/dist/layer.js"></script>

<script>
    function img_sub() {
        var tr_id=510;
        var tri_id=320;
        var p_id="lod_pic";
        var flag=0;
        var url="/add_img.php?p_id="+p_id+"&tr_id="+tr_id+"&tri_id="+tri_id+"&flag="+flag;
        //alert(url);
        layer.open({
            type: 2,
            title:"图片裁切",
            shift: 2,
            area: ['100%', '100%'],
            //shadeClose: true,
            content: [url],
            scrollbar: true ,//屏蔽浏览器滚动条
        });
    }
    function sub(){
        var title=$("#title").val();
        if(title==''){
            alert("标题不得为空");
            return;
        }
       /* var f=$("#radio1").attr("checked");
        if(f=="checked"){
            var url=$("#lod_pic").attr("src");
            $("#imgurl").val(url);
        }*/

        var url=$("#lod_pic").attr("src");
        $("#imgurl").val(url);


        $("#edit-form").submit();
    }


</script>

<script type="text/javascript">
    UE.getEditor('info', {
        theme:"default", //皮肤
        lang:"zh-cn", //语言
        initialFrameWidth:1078,  //初始化编辑器宽度,默认800
        initialFrameHeight:320//  初始化编辑器高度
    });
</script>
